#include<stdio.h>
int f(int n)
{
    int count=0;
    if(n==0)
    {
        return 1;
    }
    if(n<0)
    {
        n=-n;
        count=1;
    }
    while(n>0)
    {
        n=n/10;
        count++;
    }
    return count;
}
int main()
{
    int i;
    char ch;
    int a,b;
    scanf("%d",&i);
    int count = 0;
    char last='\0';
    int first=1;
    for(int j=0;j<i;j++)
    { 
        count=0;
     if ( first==1||scanf(" %c%d%d",&ch,&a,&b)==3)
     {
        if(first==1)
        {
            scanf(" %c%d%d",&ch,&a,&b);
            first=0;
        }
       last=ch ;
     }else
     {
        scanf("%d%d",&a,&b);
        ch=last;
     }
       if(ch=='a')
       {
        count = f(a)+f(b)+f(a+b)+2;
        printf("%d+%d=%d\n%d\n",a,b,a+b,count);
       }
       if(ch=='b')
       {
        count = f(a)+f(b)+f(a-b)+2;
        printf("%d-%d=%d\n%d\n",a,b,a-b,count);
       }
       if(ch=='c')
       {
        count = f(a)+f(b)+f(a*b)+2;
        printf("%d*%d=%d\n%d\n",a,b,a*b,count);
       }
    }
    return 0;
}